import React, { Suspense } from "react";
import { createBrowserRouter, Navigate } from "react-router-dom";
//路由懒加载
const App = React.lazy(() => import("../App"));
const ProductDetail = React.lazy(
  () => import("../components/czs/ProductDetail")
);
const Cart = React.lazy(() => import("../components/czs/Cart"));
const OrderConfirm = React.lazy(() => import("../components/czs/OrderConfirm"));
const Payment = React.lazy(() => import("../components/czs/Payment"));
const PaymentSuccess = React.lazy(
  () => import("../components/czs/PaymentSuccess")
);
const Orders = React.lazy(() => import("../components/czs/Orders"));
const Home = React.lazy(() => import("../pages/zh/Home"));
const Haha = React.lazy(() => import("../pages/zh/Haha"));
const Shopping=React.lazy(()=>import('../wang/App'))
const Login=React.lazy(()=>import('../pages/ybs/Login'))
const Register=React.lazy(()=>import('../pages/ybs/RegisterForm'))

const CustomerService=React.lazy(()=>import('../components/dpy/CustomerService'))
const CustomerServiceBackend=React.lazy(()=>import('../components/dpy/CustomerServiceBackend'))
// const ISlogin = (props) => {
//     let Com = props.children.type
//     const token = localStorage.getItem('token')
//     if(token){
//         return <Com></Com>
//     }else{
//         return <Navigate to="/login"></Navigate>
//     }
// }

const router = createBrowserRouter([
  {
    path: "/",
    element: <App></App>,
    children: [{}],
  },
  { path: "/productDetail", element: <ProductDetail></ProductDetail> },
  { path: "/cart", element: <Cart></Cart> },
  { path: "/order-confirm", element: <OrderConfirm></OrderConfirm> },
  { path: "/payment", element: <Payment></Payment> },
  { path: "/payment-success", element: <PaymentSuccess></PaymentSuccess> },
  { path: "/orders", element: <Orders></Orders> },
  { path: "/home", element: <Home></Home> },
  { path: "/haha", element: <Haha></Haha> },
  { path: "/shopping", element: <Shopping></Shopping> },
  { path: "/login", element: <Login></Login> },
  { path: "/register", element: <Register></Register> },
  { path: "/customerService", element: <CustomerService></CustomerService> },
  { path: "/customerServiceBackend", element: <CustomerServiceBackend></CustomerServiceBackend> },
]);
export default router;
